home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 April / macformat-075.iso / Shareware Plus / Games / GameMaker 2.6.1 Demo / Script Language Reference < prev    next >
Encoding:
Text File  |  1998-12-20  |  8.6 KB  |  146 lines  |  [TEXT/ttxt]

  1. GAMEMAKER SCRIPTING
  2. document updated 12/20/98
  3.  
  4. Scripting Language Reference
  5.  
  6. ALERT <your message here>
  7. Displays a simple alert window with an OK button (no icon, no beep) with the message that you type after ALERT. You can put the value of a variable in an alert by using $variable$.
  8. Example:
  9. ALERT You have $gold$ gold.
  10.  
  11. BEEP
  12. Plays the alert sound set in the Sound control monitor (usually set at "Simple Beep").
  13.  
  14. DELAY
  15. DELAY <lengthofdelay>
  16. The DELAY without any parameter will delay until any currently playing sound (if any) is completed. If you put a number after DELAY from 1 to 1000 it will delay for that amount of time (100 = 1 second).
  17.  
  18. DOMENU ABOUT | NEW | OPEN | SAVE | QUIT
  19. The DOMENU command is used with any one of the 5 menu choices (ABOUT, NEW, OPEN, SAVE, or QUIT) to execute either the "About" menu item in the "Apple" menu or one of the menu items in the "File" menu. The NEW, OPEN, and SAVE commands work even if you selected the "Use minimal menus" option in the "Game Options".
  20. Example:
  21. DOMENU OPEN
  22.  
  23. GOTOCARD <cardnumber>
  24. Opens card numbered <cardnumber>. The <cardnumber> must be either a number or variable name. It can't be a card name since card names will be treated as a variable name.
  25.  
  26. HIDEBUTTON <buttonid>
  27. Hides button number <buttonid>.
  28.  
  29. IF <trueExpression> THEN <dosomething>
  30. If the statement after the IF is true, then the code after THEN will be executed. <dosomething> can be any other command except REM.
  31. Examples:
  32. IF X = 10 THEN SOUND Wild Eep
  33. IF key <> 1 THEN ALERT You don't have the key.
  34.  
  35. IF <trueExpression> THEN
  36.   ' do something
  37. ELSE
  38.   ' do something else
  39. END IF
  40. This is a block IF command. If the satement after the IF is true, then all of the lines lines between IF and ELSE are executed. If the satement after the IF is false, then all of the lines between ELSE and END IF are executed. ELSE is optional and only needs to be used if you want statements to be executed when the IF line is false.
  41. Example:
  42. IF X = 100 THEN
  43.   SOUND You Win
  44.   GOTOCARD 99
  45. ELSE
  46.   SOUND You Lose
  47.   GOTOCARD 100
  48. END IF
  49.  
  50. LOOP MOVIE <x>
  51. Loops a currently playing QuickTime MIDI, wav, or Quicktime movie with no movie data x amount of times or until either another movie is played or a STOP MOVIE command is executed. You can leave out the x if you want the movie to loop an infinate number of times. This command should normally be placed on the line after a MOVIE command. This command does not currently work on QuickTime movies with a movie track.
  52.  
  53. LOOP SOUND <x>
  54. Loops the currently playing sound (or the last sound to be played) x amount of times or until either another sound is played or a STOP SOUND command is executed. You can leave out the x if you want the sound to loop an infinate number of times. This command should normally be placed on the line after a SOUND command.
  55.  
  56. MOVIE <horz> <vert> <nameofmovie>
  57. Plays a QuickTime movie file named <nameofmovie> at location <horz>, <vert> in the graphics area of the current card. Movies will only play if QuickTime v2.0 or better is installed and the movie file is in the same folder as your game. Coordinates for <horz> and <vert> must be numbers. They can't be variables. You can also play MIDI and wav files with the MOVIE command.
  58.  
  59. NOTE <frequency> <length> <volume>
  60. Plays any of the standard MIDI notes. <frequency> is the pitch and must be a number from 1 to 127. <length> must be a number indicating how long the note will continue playing. The length is 60 per second, not 100 per second as the DELAY command is. <volume> must be from 0 to 127 and indicates the sound volume you want to use. The volume paramter is optional. If you don't set the volume then it will default to 127 (loud).
  61.  
  62. ON TIMER <time> GOTOCARD <cardnumber>
  63. Branches to card <cardnumber> after <time> amount of time has elapsed (100 = 1 second). This only works while on the card the command was executed from. Once the game branches to another card, the TIMER is set to off. See also the TIMER OFF command.
  64.  
  65. RANDOM <rand1> <rand2> <rand3> <rand4> <rand5>
  66. Lets you choose a random number. You can have from 1 to 5 parameters. If there is only one number after RANDOM, a random number from 1 to <rand1> will be chosen. If there is 2 to 5 numbers, then a random one of those numbers will be selected.
  67. Examples:
  68. Pick a random number from 1 to 25 and put it in X:
  69.   X = RANDOM 25
  70. Randomly pick either 10, 15, or 18 and put it in X:
  71.   X = RANDOM 10 15 18
  72.  
  73. REM
  74. This is used for remarks that you want to put in your code possible to remind yourself what a certain piece of code is for. Any line starting with REM (you can also use the ' apostrophy character rather than REM) will be ignored. This must be at the beginning of a line of code. Remarks cannot be put in the middle of a line.
  75.  
  76. RESET
  77. Resets all variables to 0. It's usually a good idea to put this as the first line of the Card Script in card #1 so that anytime a player starts a new game, all variables will be reset. If you need some variables to start with a value other than 0, set them after using RESET.
  78.  
  79. SHOWBUTTON <buttonid>
  80. Shows button number <buttonid> if it was previously hidden using HIDEBUTTON.
  81.  
  82. SOUND <soundname>
  83. Plays the sound named <soundname>.
  84.  
  85. STATUSBAR <amount> <cardnumber>
  86. Adds <amount> to the status bar. A negative number moves the bar to the left and a positive number moves the bar to the right. The <cardnumber> is the card that GameMaker should go to if the bar is at 0 after adding <amount> to the bar.
  87.  
  88. STOP SOUND | MOVIE
  89. Stops playing either a sound or a QuickTime file that only has a sound track (including MIDI or wav files). It does not work with the NOTE command or QuickTime movies that have movie data.
  90. Examples:
  91. Stop playing a sound:
  92.   STOP SOUND
  93. Stop playing a QuickTime file:
  94.   STOP MOVIE
  95. Stop playing both a sound and a movie:
  96.   STOP SOUND MOVIE
  97.  
  98. SWAP <variable1> <variable2>
  99. Exchanges the value of 2 variables. If variable1 = 10 and variable2 = 20, doing a swap will set variable1 to 20 and variable2 to 10.
  100.  
  101. TIMER OFF
  102. Turns off the TIMER if it was on. See the ON TIMER command for instructions on using the TIMER.
  103.  
  104. TOGGLE <variable>
  105. Toggles variable between 0 and 1. If variable = anything other than 0 then it's set to 0. If variable = 0 then it's set to 1.
  106.  
  107.  
  108. ----------
  109. VARIABLES
  110. ----------
  111. Variables are createed in your code, not in another window ahead of time. So if you have a Button code that has:
  112.   key = 1
  113. That will create a variable named key that is equal to 1. All variables are global so you can then test to see if key = 1 in any other Button, Card, or Click Area code. You can make a variable equal to any number from -32767 to 32767. So lets say you have a button named "Get key". When a player clicks on the button, it executes your code. You could have something simple like this:
  114.   IF key = 1 THEN ALERT You already have the key.
  115.   key = 1
  116. The above code will show an alert message window if the key was already set to 1. It will then set the key to 1 in case it wasn't = to 1. The idea here is that you are keeping your own an inventory list. You can then check to see if the player has the key when they are on another card. Later in the game there can be a button named "Open Door". The code for that button can then check to see if the player got the key earlier in the game.
  117.   IF key = 1 THEN GOTOCARD 100
  118.   IF key = 0 THEN ALERT You need a key to unlock the door.
  119.  
  120. You can also make variables equal to other variables and you can add or subtract from them:
  121.   gold = gold + 10
  122.   experience = gold * 2
  123.  
  124. The limitations of variables are as follows:
  125. -There is a maximum of 50 different variables in each project.
  126. -There are no string variables except as used in the ALERT command.
  127. -Variables must be integers in the range of -32767 and 32767.
  128. -Complex math is not supported and parenthesis are not allowed. For example, X = Y + 5 will work fine, but X = Y + (Z * 5) will not.
  129. -There must be a space between names, numbers, and signs. For example:
  130.   gold=gold+10
  131. will not work because there needs to be spaces between each item, but it may not generate an error either, so you should be careful when writing these lines. This will hopefully improve in the future. The correct way to write it is:
  132.   gold = gold + 10
  133.  
  134.  
  135. --------------------
  136. BUILT-IN VARIABLES
  137. --------------------
  138. Counter
  139. The value of this variable will be displayed in the bottom right of the main window if you have enabled the Counter in the "Game Options" menu. The display will automatically be updated whenever you change its value in any of the scripts.
  140.  
  141. Barvalue
  142. This variable returns the current value of the Status Bar. You can also use it to set the value of the Status Bar. For other ways of using the Status Bar, see the STATUSBAR command.
  143.  
  144. Recentcard
  145. This variable always returns the number of the most recent card that the player was on. It should not be directly changed in scripts.
  146.